package com.lrkj.back.service.impl;

import java.util.List;
import java.util.Map;

import com.lrkj.back.entity.ZsYicipinKucun;
import com.lrkj.back.mapper.ZsYicipinKucunMapper;
import com.lrkj.back.service.ZsYicipinKucunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.cbons.mamisay.parent.db.api.DBInterface;
import cn.com.cbons.mamisay.parent.exception.DBException;
import cn.com.cbons.mamisay.parent.service.base.ParentServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Transactional
@Service("kucunService")
public class ZsYicipinKucunServiceImpl extends ParentServiceImpl<ZsYicipinKucun> implements ZsYicipinKucunService {
    @Autowired
    private ZsYicipinKucunMapper kucunMapper;

    @Override
    protected DBInterface<ZsYicipinKucun> getDao() throws DBException {
        return kucunMapper;
    }

    @Override
    public PageInfo<ZsYicipinKucun> findAllYicipinKucun(Map<String, Object> map) throws DBException {
        PageHelper.startPage(Integer.valueOf(map.get("pageNo").toString()),
                Integer.valueOf(map.get("pageSize").toString()));
        List<ZsYicipinKucun> dataList = kucunMapper.findAllYicipinKucun(map);
        PageInfo<ZsYicipinKucun> page = new PageInfo<ZsYicipinKucun>(dataList);
        return page;
    }

    @Override
    public List<ZsYicipinKucun> findYicipinKucun(Map<String, Object> map) throws DBException {
        List<ZsYicipinKucun> dataList = kucunMapper.findAllYicipinKucun(map);
        return dataList;
    }

    @Override
    public int updateKucun(String productId, Integer num) throws DBException {
        return kucunMapper.updateKucun(productId, num);
    }

    @Override
    public int updateByBatch(List<ZsYicipinKucun> yicipinKucuns) throws DBException {
        return kucunMapper.updateByBatch(yicipinKucuns);
    }

}
